
import { _decorator, Color, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { secondGun_specialSkill_config } from '../manager/AppControll';
import { Loader } from '../tools/LoadManger';
import { load } from '../ui/Load';
import { DataHelper } from '../system/DataHelper';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = NewComponent
 * DateTime = Sun Jun 11 2023 11:11:41 GMT+0800 (GMT+08:00)
 * Author = guoxun
 * FileBasename = NewComponent.ts
 * FileBasenameNoExtension = NewComponent
 * URL = db://assets/script/pop/NewComponent.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */

@ccclass('SecondGunListItem')
export class SecondGunListItem extends Component {
    private mSpfGun: SpriteFrame = null;
    private mLbIndex: Label = null;
    private mLbDec: Label = null;
    private mLbName: Label = null;
    private mConfig: secondGun_specialSkill_config = null;
    private mLbAtkAdd: Label = null;
    protected onLoad(): void {
    }

    InitData(config: secondGun_specialSkill_config) {
        this.mLbIndex = this.node.getChildByName("xuhao").getComponent(Label);
        this.mLbDec = this.node.getChildByName("skillDec").getComponent(Label);
        this.mLbName = this.node.getChildByName("gunName").getComponent(Label);
        this.mLbAtkAdd = this.node.getChildByName("atkAdd").getComponent(Label);
        this.mConfig = config;
        this.InitView();
    }

    InitView() {
        Loader.LoadImage("image/gun/secondaryGun/" + this.mConfig.secondGunTDRes, (spf) => {
            if (this.node) {
                this.node.getChildByName("gunSprite").getComponent(Sprite).spriteFrame = spf;
            }
        })
        this.mLbIndex.string = this.mConfig.GunRank;
        this.mLbDec.string = this.mConfig.skillDescribe;
        this.mLbName.string = this.mConfig.secondGunName;
        this.mLbName.color = new Color(DataHelper.GetColorByLv(this.mConfig.skillQuality + 1).value);
        this.mLbAtkAdd.string = this.mConfig.atkAdd;
    }

    start() {
        // [3]
    }


}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
